<!DOCTYPE html>
<html id="root" lang="en" xmlns:th="http://www.w3.org/1999/xhtml">
<head>
    <base href=""/>
    <meta charset="UTF-8"/>
    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no"/>
    <title>登录确认</title>
    <link type="text/css" rel="stylesheet" href="./css/style.css" media="screen"/>
    <link type="text/css" rel="stylesheet" href="./css/weui.min.css" media="screen"/>
    <script type='text/javascript' src='./js/jquery-1.10.2.min.js'></script>
    <script type='text/javascript' src='./js/screen.js'></script>
    <script type='text/javascript' src="./js/common.js"></script>
</head>
<body>
<div class="container">
    <div class="topup-page">
        <div class="message">
            <p id="message">你确认要登录公众号服务<br/>iev365吗？</p>
        </div>
        <div class="btn">
            <a href="javascript:void(0);" class="confirm right" style="width:5rem">确认</a>
            <a href="javascript:void(0);" class="cancel close right" style="width:5rem">取消</a>
        </div>
    </div>
</div>
<script th:inline="javascript">
    $(document).ready(function() {
        setBaseUrl();
    })
    var uuid = [[${uuid}]];
    $('.close').click(function(){
        WeixinJSBridge.call('closeWindow');
    });
    $('.confirm').click(function(){
        $.ajax({
            url : "confirmLogin",
            type : 'get',
            dataType : 'json',
            data: {uuid: uuid},
            success : function(data) {
                var result = data.result;
                if (result == "Success") {
                    if (data.url) {
                        window.location.href = getRootPath() + data.url;
                     } else {
                        $("#message").html("登录确认成功，参数错误");
                        $(".confirm").hide();
                     }
                } else if (result == "Invalid") {
                    $(".confirm").hide();
                    $("#message").html("登录失败，二维码失效");
                } else if (result == "Timeout") {
                    $(".confirm").hide();
                    $("#message").html("登录失败，二维码失效");
                } else {
                    $(".confirm").hide();
                    $('#message').css({color: "#ff0000"});
                    $("#message").html("登录确认异常，请重新尝试");
                }
            },
            timeout: function(data){
                $(".confirm").hide();
                $('#message').css({color: "#ff0000"});
                $("#message").html("登录超时，请重新扫码登录");
            },
            error : function(data) {
                $(".confirm").hide();
                $('#message').css({color: "#ff0000"});
                $("#message").html("登录异常，请重新扫码登录或联系管理员处理");
            }
        })
    });
</script>
</body>
</html>